﻿@using System.Web.UI.WebControls
@model IEnumerable<WebTV_Kickstarter.Project>

@{
    ViewBag.Title = "Overzicht Projecten";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Overzicht Projecten</h2>

<p>
    @(ViewBag.isAdmin ? Html.ActionLink("Maak een nieuw project aan", "Create") : null)
</p>
<table class="table">
    <tr>
        <th>
            Titel
        </th>
        <th>
            Gedoneerd
        </th>
        <th>
            Eigenaar
        </th>
        <th>
            Rating
        </th>
        <th>
            Berichten
        </th>
        <th></th>
    </tr>   

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Title)
        </td>
        <td>
            @string.Format("{0:C}", ((decimal)item.TotalAmount)).Replace('$', '€')
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.User.Name)
        </td>
        <td>
            @Math.Round((double)item.TotalRating / (double)item.NumberOfVotes,1)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.NumberOfMessages)
        </td>
        <td>
            @Html.ActionLink("Details | ", "Details", new { id = item.Id }) 
            @(ViewBag.isAdmin ? Html.ActionLink("Aanpassen | ", "Edit", new { id = item.Id }, new { @style = "color: #b8860b;" }) : null)
            @(ViewBag.isAdmin ? Html.ActionLink("Verwijder | ", "Delete", new { id = item.Id }, new { @style = "color: #8b0000;" }) : null) 
            
            @Html.ActionLink("Doneer", "../Donation/Donate", new { id= item.Id}) | 
            @Html.ActionLink("Beoordeel", "../Rating/Beoordeel", new { id = item.Id }) |
            @Html.ActionLink("Reageer", "../Message/Create", new { id = item.Id })
        </td>
    </tr>
}

</table>
